package com.wejoy.video.middle.station.data.enums.wechat;

import com.wejoy.video.middle.station.data.exception.BusinessException;
import org.apache.commons.lang3.StringUtils;

/**
 * 微信枚举
 *
 * @author admin
 */
public enum EnumWechat {

    MP(1, "", ""),
    ;

    EnumWechat(Integer code, String appId, String secret) {
        this.code = code;
        this.appId = appId;
        this.secret = secret;
    }

    Integer code;
    String appId;
    String secret;

    public static EnumWechat getByAppId(String appId) {
        if (StringUtils.isEmpty(appId)) {
            return null;
        }
        for (EnumWechat type : EnumWechat.values()) {
            if (type.getAppId().equals(appId)) {
                return type;
            }
        }
        throw new BusinessException("类型非法");
    }

    public static EnumWechat getByCode(Integer code) {
        if (null == code) {
            return null;
        }
        for (EnumWechat type : EnumWechat.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new BusinessException("类型非法");
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }
}
